﻿
module("FallingZReversed.init")
test("FallingZReversed init", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingZReversed = new tetris.FallingZReversed(x, y, color);
    equal(5, fallingZReversed.center.x, "CenterX of FallingZReversed is set");
    equal(6, fallingZReversed.center.y, "CenterY of FallingZReversed is set");

    var relativeBody="";
    for (var i = 0; i < fallingZReversed._relativeBody.length; i++) {
        relativeBody += fallingZReversed._relativeBody[i].coordinate.toString() + " ";
    }
    equal("(1,0) (0,0) (0,1) (-1,1) ", relativeBody, "CenterY of FallingZReversed is set");

    var body= "";
    for (var i = 0; i < fallingZReversed.getBody.length; i++) {
        body += fallingZReversed.getBody[i].coordinate.toString() + " ";
    }
    equal("(6,6) (5,6) (5,7) (4,7) ", body, "CenterY of FallingZReversed is set");
});

test("FallingZReversed moveTo", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingZReversed = new tetris.FallingZReversed(x, y, color);
    fallingZReversed.moveTo(7, 8);

    deepEqual(7, fallingZReversed.center.x, "CenterX of FallingZReversed is set to new x");
    equal(8, fallingZReversed.center.y, "CenterY of FallingZReversed is set to new y");

    var relativeBody = "";
    for (var i = 0; i < fallingZReversed._relativeBody.length; i++) {
        relativeBody += fallingZReversed._relativeBody[i].coordinate.toString() + " ";
    }
    equal("(1,0) (0,0) (0,1) (-1,1) ", relativeBody, "CenterY of FallingZReversed is set");

    var body = "";
    for (var i = 0; i < fallingZReversed.getBody.length; i++) {
        body += fallingZReversed.getBody[i].coordinate.toString() + " ";
    }
    equal("(8,8) (7,8) (7,9) (6,9) ", body, "CenterY of FallingZReversed is set");
});

test("FallingZReversed moveRight", function () {
    var x = 5;
    var y = 8;
    var color = "#FF00FF";

    var fallingZReversed = new tetris.FallingZReversed(x, y, color);
    fallingZReversed.moveRight(); 
    deepEqual(6, fallingZReversed.center.x, "CenterX of FallingZReversed is set to x+1");
    equal(8, fallingZReversed.center.y, "CenterY of FallingZReversed is same");
});

test("FallingZReversed moveLeft", function () {
    var x = 5;
    var y = 8;
    var color = "#FF00FF";

    var fallingZReversed = new tetris.FallingZReversed(x, y, color);
    fallingZReversed.moveLeft();
    deepEqual(4, fallingZReversed.center.x, "CenterX of FallingZReversed is set to x-1");
    equal(8, fallingZReversed.center.y, "CenterY of FallingZReversed is same");
});

test("FallingZReversed moveUp", function () {
    var x = 5;
    var y = 8;
    var color = "#FF00FF";

    var fallingZReversed = new tetris.FallingZReversed(x, y, color);
    fallingZReversed.moveUp();
    equal(5, fallingZReversed.center.x, "CenterX of FallingZReversed is same");
    equal(7, fallingZReversed.center.y, "CenterY of FallingZReversed is set to y-1");
});

test("FallingZReversed moveDown", function () {
    var x = 5;
    var y = 8;
    var color = "#FF00FF";

    var fallingZReversed = new tetris.FallingZReversed(x, y, color);
    fallingZReversed.moveDown();
    equal(5, fallingZReversed.center.x, "CenterX of FallingZReversed is same");
    equal(9, fallingZReversed.center.y, "CenterY of FallingZReversed is set to y+1");
});

test("FallingZReversed rotate", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingZReversed = new tetris.FallingZReversed(x, y, color);
    fallingZReversed.rotate();
    equal(90, fallingZReversed.rotation, "Rotation of FallingZReversed is set to 90");
});

test("FallingZReversed rotate twice", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingZReversed = new tetris.FallingZReversed(x, y, color);
    fallingZReversed.rotate();
    equal(90, fallingZReversed.rotation, "Rotation of FallingZReversed is set to 90");
    fallingZReversed.rotate();
    equal(180, fallingZReversed.rotation, "Rotation of FallingZReversed is set to 180");
});

test("FallingZReversed rotateBack", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingZReversed = new tetris.FallingZReversed(x, y, color);
    fallingZReversed.rotateBack();
    equal(270, fallingZReversed.rotation, "Rotation of FallingZReversed is set to 270");   
});

test("FallingZReversed rotateTo", function () {
    var x = 5;
    var y = 6;
    var color = "#FF00FF";

    var fallingZReversed = new tetris.FallingZReversed(x, y, color);
    fallingZReversed.rotateTo(180);
    equal(180, fallingZReversed.rotation, "Rotation of FallingZReversed is set to 180");
});

